home *** CD-ROM | disk | FTP | other *** search
- // EnergyServPub.h
- // Apple Macintosh Developer Technical Support
- //
- // Contains: Header file for the ESInit.
- //
- // Copyright (work in progress) Apple Computer, Inc All rights reserved.
- //
- // You may incorporate this sample code into your applications without
- // restriction, though the sample code has been provided "AS IS" and the
- // responsibility for its operation is 100% yours. However, what you are
- // not permitted to do is to redistribute the source as "DSC Sample Code"
- // after having made changes. If you're going to re-distribute the source,
- // we require that you make it clear in the source that the code was
- // descended from Apple Sample Code, but that you've made changes.
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- /* #include <ConditionalMacros.h> */
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
- /* #include <MixedMode.h> */
- /* #include <QuickdrawText.h> */
-
- #pragma options align=mac68k
- typedef struct {
-
- short version; // version of the data structure this one is 1
- long EnergySaverFeatures; // a long showing what features are supported
-
- // Idle Sleep & ShutDown stuff
- // the following are defined in minutes.
- // 0 minutes, or >60 minutes means never
-
- unsigned long dimIdleTime; //number of minutes before the screen sleeps
- unsigned long spinDownIdleTime; //number of minutes before the HD spins down ( desktops must be >30 for now)
- unsigned long sleepIdleTime; //number of minutes prior to system sleep
-
- short idleFlags; // defines which idle time features we support
- short unused6; // reserved
- short unused7; // reserved
-
- // Schedule Sleep & Shut Down stuff
- // These times are in minutes from midnight (actually minutes from 12:00:01 AM...)
-
- unsigned long mainWUTime; // Time computer starts up in general
- unsigned long mainSDTime; // time computer shuts down in general
-
- short WUFields; // bit fields telling which day of the week startup is enabled for
- short SDFields; // bit fields telling which day of week shutdown is enabled for
-
- // usually the same as the in general time, but the following 14 fields let you specify different times of the day
- // for startup and shutdown for each individual day. You should set all WU's to mainWUTime and all SD fields to mainSDTime
- // if you are not going to allow specific daily schedules. This is what energysaver does.
- unsigned long SDMonTime;
- unsigned long SDTueTime;
- unsigned long SDWedTime;
- unsigned long SDThuTime;
- unsigned long SDFriTime;
- unsigned long SDSatTime;
- unsigned long SDSunTime;
-
- unsigned long WUMonTime;
- unsigned long WUTueTime;
- unsigned long WUWedTime;
- unsigned long WUThuTime;
- unsigned long WUFriTime;
- unsigned long WUSatTime;
- unsigned long WUSunTime;
-
- // Sleep Prefs Info stuff
- short unused1;
- short WUSoundResID; // ID of the sound resource to play when waking up from sleep
- short unused5;
-
- // Startup Prefs Info
- short SUReopenFiles; // flags that define how we do the shutdown/restart file saving crap
- short AppFlags; // Always set to 0 in new pref file.
- short NonComplianceFlag; // set if base machine sleeps over 30 watts
-
- // Shutdown Prefs Info
- short SDIdleTime;
- short SDNotifyFlags;
- short SDNotifyDelayTime;
- short SDSoundResID;
- short SDNewFileAlias;
- short SDSavedFileAlias;
-
- // Energy Saver General prefs info
- Point oldWin300Pos; // don't use this, it belongs to the energysaver
- Boolean unused8;
- } GlobDataRecord, *GlobDataPtr, **GlobDataHand;
-
-
-
-
- #define xESLoadPreferences 1
- #define xESGetPreferences 2
- #define xESSetPreferences 3
- #define xESRefreshSettings 4
- #define xESSavePreferences 5
- #define xESAddNoteProc 6
- #define xESRemoveNoteProc 7
- #define xESRestoreDefaults 8
- #define xESGetUnsavedFolder 9
- #define xESSetUnsavedFolder 10
- #define xESGetINITVersion 11
- #define xESGetAliasFileName 12
-
- #define xNoteNewESData 1
- #define xNoteESDataReq 2
-
- typedef pascal long (*ESRoutineCallPtr)(short selector, long parm1, long parm2);
- typedef pascal long (*ESNotifyProcPtr)(short selector, GlobDataPtr theData);
-
- #if GENERATINGCFM
- typedef UniversalProcPtr ESRoutineUPP;
- #else
- typedef ESRoutineCallPtr ESRoutineUPP;
- #endif
-
- enum {
- uppESRoutineInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
- };
-
- #if GENERATINGCFM
- #define NewESRoutineProc(userRoutine) \
- (ESRoutineUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppESRoutineInfo, GetCurrentArchitecture())
- #else
- #define NewESRoutineProc(userRoutine) \
- ((ESRoutineUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallESRoutineProc(userRoutine, selector, parm1, parm2) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppESRoutineInfo, (selector), (parm1), (parm2))
- #else
- #define CallESRoutineProc(userRoutine, selector, parm1, parm2) \
- (*(userRoutine))((selector), (parm1), (parm2))
- #endif
-
- typedef struct {
- ESRoutineCallPtr WinkleINITMain; /* Main entry point for the Winkle INIT */
- char RestOfTheData[1];
- } ESData, *ESDataPtr, **ESDataHand;
- #pragma options align=reset
-
-
- // Public routines used by calling applciations
- // The ESLoadPreferences routine will fill the GlobDataPtr passed with the
- // preferences from the energy saver prefs file
- // or from the default set if the energy saver pref file does not exist.
- // Applications should not use this in general unless
- // they are reverting to the saved version for some reason
-
- OSErr ESLoadPreferences(GlobDataPtr thePrefs);
-
- // Load the current working prefs that the energy services library is
- // using. This will tell you what the current active
- // settings are for the energy services lib.
-
- OSErr ESGetPreferences(GlobDataPtr thePrefs);
-
- // ESSetPreferences simply updates the energy services libraries
- // preferences without applying the changes. Apps should not use this call
- // unless they are simply trying to communicate the information at suspend
- // time. (you know the suspend event...)
-
- OSErr ESSetPreferences(GlobDataPtr thePrefs);
-
- // ESRefreshSettings takes whatever settings the INIT currently is holding
- // and applies them. You could use this in conjunction with
- // ESSetPreferences, except that would be stupid since the next call.,..
-
- OSErr ESRefreshSettings();
-
- // ESSavePreferences copies the passed prefs to the INIT, applies the
- // changes to the power manager and running time manager tasks
- // and saves them to the energy saver prefs file so that when you reboot
- // life is good. This is how you should usually save
- // the prefs to the INIT
-
- OSErr ESSavePreferences(GlobDataPtr thePrefs);
-
- // ESAddNoteProc, ESRemoveNoteProc are here so that if you care about when
- // the energy saver prefs are being read or written you can be notified
- // your notification procedure is called when someone is asking for the
- // prefs you will be called with the filled in GlobData and the
- // selector xNoteESDataReq. This way you can see when someone wants the
- // prefs and you could always modify them on the fly if you wanted to
- // You are also called when someone copies new prefs to the INIT with a
- // xNoteNewESData selector. You then get a chance to change the data that
- // they have copied into the INIT, but you get to it before its applied. I
- // use these routines to dynamically update the displays of my apps
- // not to filter data, but I suppose you could do either.
-
- OSErr ESAddNoteProc(ESNotifyProcPtr theProc, long data);
- OSErr ESRemoveNoteProc(ESNotifyProcPtr theProc);
-
- // ESRestoreDefaults is used to put the machine back in the exact state it
- // was when it was shipped. You also get a copy of the globdata
- // so that you can see what those defaults are. Getting the globdata is
- // convenient so that you can update your HI to reflect the current machine state
- // use this in response to a "Apple Defaults" menu item maybe...
-
- OSErr ESRestoreDefaults(GlobDataPtr thePrefs);
-
- // ESGetUnsavedFolder, ESSetUnsavedFolder are dumb, and not really anything
- // you should use. So don't, or do see what I care.
-
- OSErr ESGetUnsavedFolder(Ptr theString);
- OSErr ESSetUnsavedFolder(Ptr theString);
-
- // ESGetINITVersion will return a copy of the vers resource from the INIT
- // so's you can see what version you are working with
-
- OSErr ESGetINITVersion(Handle* theVers);
-
-
-
-